﻿package mvc_view
{
	import flash.display.*;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import mvc_model.*;
	
	public class ProjectsPageView extends View
	{
		private var _container:MovieClip;
		private var _loader:Loader;
		
		public function ProjectsPageView(container:MovieClip)
		{
			_container = container;
			_loader = new Loader();
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
		}
		
		override public function update(event:Event = null):void
		{
			// load avatar image with url from xml file
			_loader.load(new URLRequest("http://localhost/Jobs4Nerds/Avatars/project.jpg"));

			// update user data from model
			if (_container == null) trace("container null");
			_container.project_nerd_txt.text = model.myToString();
		}
		
		private function imageLoaded(event:Event):void
		{
			_container.projectNerd.addChild(_loader);
		}
	}
}